package com.bro.person.admin.utils;


import java.util.*;

/**
 * @author swallow
 * Created by swallow on 2018/11/15.<br>
 */
public class Calcaulates {


    public static void main(String[] args) {

        Map<Character,Integer> mathSymbolMap = new HashMap<>();
        mathSymbolMap.put('+',1);
        mathSymbolMap.put('-',1);
        mathSymbolMap.put('*',2);
        mathSymbolMap.put('/',2);
        Set<Character> mathSymbolSet = mathSymbolMap.keySet();

        String infixExpression = "92+(88*(2-5))+100/22";
        //转成 后缀表达式

        Stack<Character> stack = new Stack<>();
        List<String> suffixExpressionList = new ArrayList<>();

        char[] chars = infixExpression.trim().toCharArray();

        //数字长度的记录值
        int len = 0;
        for (int i = 0; i < chars.length; i++) {
            //当前 处理的字符
            char ch = chars[i];

            //如果内部是空格 直接跳过
            if(Character.isSpaceChar(ch)){
                continue;
            }
            //如果是数字 记录值 直接+1
            if(Character.isDigit(ch)){
                len ++;
            }
            //如果是( 符号 直接入栈
            if(ch=='('){
                stack.add(ch);
            }
            if(mathSymbolSet.contains(ch)){
                stack.add(ch);

            }
        }
    }

}
